package com.rzj.sys_lab_assistant.service.impl;

import com.rzj.sys_lab_assistant.dao.AssistantMapper;
import com.rzj.sys_lab_assistant.entity.Assistant;
import com.rzj.sys_lab_assistant.entity.bo.AssistantBO;
import com.rzj.sys_lab_assistant.service.IAssistantService;
import com.rzj.sys_lab_assistant.utils.TimeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: sys_lab_assistant
 * @description:
 * @author: 作者
 * @create: 2021-06-29 19:33
 */
@Service
public class AssistantServiceImpl implements IAssistantService {

    @Autowired
    AssistantMapper assistantMapper;

    TimeUtils timeUtils;

    @Override
    public List<AssistantBO> listAssistants() {
        return assistantMapper.listAssistants();
    }

    @Override
    public List<AssistantBO> listAssistantsById(String account) {
        return assistantMapper.listAssistantsById(account);
    }

    @Override
    public AssistantBO getAssistantById(int aId) {
        return assistantMapper.getAssistantById(aId);
    }

    @Override
    public int addAssistant(Assistant assistant) {
        assistant.setCreateTime(timeUtils.getTime());
        assistant.setModifyTime(timeUtils.getTime());

        return assistantMapper.saveAssistant(assistant);
    }

    @Override
    public int editAssistant(Assistant assistant) {
        assistant.setModifyTime(timeUtils.getTime());
        return assistantMapper.updateAssistant(assistant);
    }

    @Override
    public int editAssistantByStatus(int aId) {
        Assistant assistant = new Assistant();
        assistant.setAId(aId);
        assistant.setModifyTime(timeUtils.getTime());
        assistant.setStatus(1);
        return assistantMapper.updateAssistantByStatus(assistant);
    }

    @Override
    public int delAssistant(int aId) {
        return assistantMapper.deleteAssistant(aId);
    }

}
